diff -r 545ba1b126ca tools/libxc/xc_linux_build.c
authordjm@kirby.fc.hp.com <djm@kirby.fc.hp.com>
Wed, 21 Dec 2005 15:07:09 +0000 (09:07 -0600)
committerdjm@kirby.fc.hp.com <djm@kirby.fc.hp.com>
Wed, 21 Dec 2005 15:07:09 +0000 (09:07 -0600)
--- a/tools/libxc/xc_linux_build.c      Tue Dec 20 20:11:17 2005
+++ b/tools/libxc/xc_linux_build.c      Wed Dec 21 11:50:08 2005
@@ -296,9 +296,13 @@
     unsigned long *page_array = NULL;
     struct load_funcs load_funcs;
     struct domain_setup_info dsi;
+    unsigned long vinitrd_start;
+    unsigned long vinitrd_end;
+    unsigned long v_end;
     unsigned long start_page, pgnr;
     start_info_t *start_info;
     int rc;
+    unsigned long i;

     rc = probeimageformat(image, image_size, &load_funcs);
     if ( rc != 0 )
@@ -310,11 +314,13 @@
     if ( rc != 0 )
         goto error_out;

-    dsi.v_start = round_pgdown(dsi.v_start);
-    dsi.v_end   = round_pgup(dsi.v_end);
+    dsi.v_start      = round_pgdown(dsi.v_start);
+    vinitrd_start    = round_pgup(dsi.v_end);
+    vinitrd_end      = vinitrd_start + initrd_len;
+    v_end            = round_pgup(vinitrd_end);

     start_page = dsi.v_start >> PAGE_SHIFT;
-    pgnr = (dsi.v_end - dsi.v_start) >> PAGE_SHIFT;
+    pgnr = (v_end - dsi.v_start) >> PAGE_SHIFT;
     if ( (page_array = malloc(pgnr * sizeof(unsigned long))) == NULL )
     {
         PERROR("Could not allocate memory");
@@ -326,9 +332,38 @@
         PERROR("Could not get the page frame list");
         goto error_out;
     }
+
+#define _p(a) ((void *) (a))
+
+    printf("VIRTUAL MEMORY ARRANGEMENT:\n"
+           " Loaded kernel: %p->%p\n"
+           " Init. ramdisk: %p->%p\n"
+           " TOTAL:         %p->%p\n",
+           _p(dsi.v_kernstart), _p(dsi.v_kernend),
+           _p(vinitrd_start),   _p(vinitrd_end),
+           _p(dsi.v_start),     _p(v_end));
+    printf(" ENTRY ADDRESS: %p\n", _p(dsi.v_kernentry));

     (load_funcs.loadimage)(image, image_size, xc_handle, dom, page_array,
                            &dsi);
+
+    /* Load the initial ramdisk image. */
+    if ( initrd_len != 0 )
+    {
+        for ( i = (vinitrd_start - dsi.v_start);
+              i < (vinitrd_end - dsi.v_start); i += PAGE_SIZE )
+        {
+            char page[PAGE_SIZE];
+            if ( gzread(initrd_gfd, page, PAGE_SIZE) == -1 )
+            {
+                PERROR("Error reading initrd image, could not");
+                goto error_out;
+            }
+            xc_copy_to_domain_page(xc_handle, dom,
+                                   page_array[i>>PAGE_SHIFT], page);
+        }
+    }
+

     *pvke = dsi.v_kernentry;

@@ -358,6 +393,13 @@
     start_info->store_evtchn = store_evtchn;
     start_info->console_mfn   = nr_pages - 1;
     start_info->console_evtchn = console_evtchn;
+    if ( initrd_len != 0 )
+    {
+        ctxt->initrd.start    = vinitrd_start;
+        ctxt->initrd.size     = initrd_len;
+    }
+    strncpy((char *)ctxt->cmdline, cmdline, IA64_COMMAND_LINE_SIZE);
+    ctxt->cmdline[IA64_COMMAND_LINE_SIZE-1] = '\0';
     munmap(start_info, PAGE_SIZE);

     free(page_array);
diff -r 545ba1b126ca xen/arch/ia64/xen/dom_fw.c
--- a/xen/arch/ia64/xen/dom_fw.c        Tue Dec 20 20:11:17 2005
+++ b/xen/arch/ia64/xen/dom_fw.c        Wed Dec 21 11:50:08 2005
@@ -861,9 +861,14 @@
        bp->console_info.orig_x = 0;
        bp->console_info.orig_y = 24;
        bp->fpswa = 0;
-        bp->initrd_start = (dom0_start+dom0_size) -
-                (PAGE_ALIGN(ia64_boot_param->initrd_size) + 4*1024*1024);
-        bp->initrd_size = ia64_boot_param->initrd_size;
+        if (d == dom0){
+                bp->initrd_start = (dom0_start+dom0_size) -
+                        (PAGE_ALIGN(ia64_boot_param->initrd_size) + 4*1024*1024);
+                bp->initrd_size = ia64_boot_param->initrd_size;
+        }else{
+                bp->initrd_start = d->arch.initrd_start;
+                bp->initrd_size  = d->arch.initrd_len;
+       }
                 printf(" initrd start %0xlx", bp->initrd_start);
                 printf(" initrd size %0xlx", bp->initrd_size);

diff -r 545ba1b126ca xen/arch/ia64/xen/domain.c
--- a/xen/arch/ia64/xen/domain.c        Tue Dec 20 20:11:17 2005
+++ b/xen/arch/ia64/xen/domain.c        Wed Dec 21 11:50:08 2005
@@ -297,6 +297,9 @@

        *regs = c->regs;
        d->arch.sys_pgnr = c->sys_pgnr;
+        d->arch.initrd_start = c->initrd.start;
+        d->arch.initrd_len   = c->initrd.size;
+        d->arch.cmdline      = c->cmdline;
        new_thread(v, regs->cr_iip, 0, 0);

        v->vcpu_info->arch.evtchn_vector = c->vcpu.evtchn_vector;
@@ -365,7 +368,7 @@
                    regs->r28 = dom_fw_setup(d,saved_command_line,256L);
                else {
                    regs->ar_rsc |= (2 << 2); /* force PL2/3 */
-                   regs->r28 = dom_fw_setup(d,"nomca nosmp xencons=tty0 console=tty0 root=/dev/hda1",256L);  //FIXME
+                   regs->r28 = dom_fw_setup(d,d->arch.cmdline,256L);
                }
                VCPU(v, banknum) = 1;
                VCPU(v, metaphysical_mode) = 1;
diff -r 545ba1b126ca xen/include/asm-ia64/domain.h
--- a/xen/include/asm-ia64/domain.h     Tue Dec 20 20:11:17 2005
+++ b/xen/include/asm-ia64/domain.h     Wed Dec 21 11:50:08 2005
@@ -38,6 +38,9 @@
     u64 image_len;
     u64 entry;
 #endif
+    unsigned long initrd_start;
+    unsigned long initrd_len;
+    char *cmdline;
 };
 #define xen_vastart arch.xen_vastart
 #define xen_vaend arch.xen_vaend
diff -r 545ba1b126ca xen/include/public/arch-ia64.h
--- a/xen/include/public/arch-ia64.h    Tue Dec 20 20:11:17 2005
+++ b/xen/include/public/arch-ia64.h    Wed Dec 21 11:50:08 2005
@@ -276,6 +276,12 @@
     unsigned long start_info_pfn;
 } arch_shared_info_t;

+typedef struct {
+    unsigned long start;
+    unsigned long size;
+} arch_initrd_info_t;
+
+#define IA64_COMMAND_LINE_SIZE 512
 typedef struct vcpu_guest_context {
 #define VGCF_FPU_VALID (1<<0)
 #define VGCF_VMX_GUEST (1<<1)
@@ -289,6 +295,8 @@
     cpu_user_regs_t regs;
     arch_vcpu_info_t vcpu;
     arch_shared_info_t shared;
+    arch_initrd_info_t initrd;
+    char cmdline[IA64_COMMAND_LINE_SIZE];
 } vcpu_guest_context_t;

 #endif /* !__ASSEMBLY__ */

tools/libxc/xc_linux_build.c
xen/arch/ia64/xen/domain.c
xen/include/asm-ia64/domain.h
xen/include/public/arch-ia64.h

index 1afea3cb39b13320a25562164ad5c2f7da8c7e22..73f0c87aa37cb796ac0809cef374f410cdd53ada 100644 (file)
@@ -296,9 +296,13 @@ static int setup_guest(int xc_handle,
     unsigned long *page_array = NULL;
     struct load_funcs load_funcs;
     struct domain_setup_info dsi;
+    unsigned long vinitrd_start;
+    unsigned long vinitrd_end;
+    unsigned long v_end;
     unsigned long start_page, pgnr;
     start_info_t *start_info;
     int rc;
+    unsigned long i;
 
     rc = probeimageformat(image, image_size, &load_funcs);
     if ( rc != 0 )
@@ -310,11 +314,13 @@ static int setup_guest(int xc_handle,
     if ( rc != 0 )
         goto error_out;
 
-    dsi.v_start = round_pgdown(dsi.v_start);
-    dsi.v_end   = round_pgup(dsi.v_end);
+    dsi.v_start      = round_pgdown(dsi.v_start);
+    vinitrd_start    = round_pgup(dsi.v_end);
+    vinitrd_end      = vinitrd_start + initrd_len;
+    v_end            = round_pgup(vinitrd_end);
 
     start_page = dsi.v_start >> PAGE_SHIFT;
-    pgnr = (dsi.v_end - dsi.v_start) >> PAGE_SHIFT;
+    pgnr = (v_end - dsi.v_start) >> PAGE_SHIFT;
     if ( (page_array = malloc(pgnr * sizeof(unsigned long))) == NULL )
     {
         PERROR("Could not allocate memory");
@@ -327,9 +333,38 @@ static int setup_guest(int xc_handle,
         goto error_out;
     }
 
+#define _p(a) ((void *) (a))
+
+    printf("VIRTUAL MEMORY ARRANGEMENT:\n"
+           " Loaded kernel: %p->%p\n"
+           " Init. ramdisk: %p->%p\n"
+           " TOTAL:         %p->%p\n",
+           _p(dsi.v_kernstart), _p(dsi.v_kernend), 
+           _p(vinitrd_start),   _p(vinitrd_end),
+           _p(dsi.v_start),     _p(v_end));
+    printf(" ENTRY ADDRESS: %p\n", _p(dsi.v_kernentry));
+
     (load_funcs.loadimage)(image, image_size, xc_handle, dom, page_array,
                            &dsi);
 
+    /* Load the initial ramdisk image. */
+    if ( initrd_len != 0 )
+    {
+        for ( i = (vinitrd_start - dsi.v_start);
+              i < (vinitrd_end - dsi.v_start); i += PAGE_SIZE )
+        {
+            char page[PAGE_SIZE];
+            if ( gzread(initrd_gfd, page, PAGE_SIZE) == -1 )
+            {
+                PERROR("Error reading initrd image, could not");
+                goto error_out;
+            }
+            xc_copy_to_domain_page(xc_handle, dom,
+                                   page_array[i>>PAGE_SHIFT], page);
+        }
+    }
+
+
     *pvke = dsi.v_kernentry;
 
     /* Now need to retrieve machine pfn for system pages:
@@ -358,6 +393,13 @@ static int setup_guest(int xc_handle,
     start_info->store_evtchn = store_evtchn;
     start_info->console_mfn   = nr_pages - 1;
     start_info->console_evtchn = console_evtchn;
+    if ( initrd_len != 0 )
+    {
+        ctxt->initrd.start    = vinitrd_start;
+        ctxt->initrd.size     = initrd_len;
+    }
+    strncpy((char *)ctxt->cmdline, cmdline, IA64_COMMAND_LINE_SIZE);
+    ctxt->cmdline[IA64_COMMAND_LINE_SIZE-1] = '\0';
     munmap(start_info, PAGE_SIZE);
 
     free(page_array);
index e3fbd628b761b4350c0a2640a526b6c9c75d9e21..9f868ade73aca079f9c653a300fde093ed15aaef 100644 (file)
@@ -286,6 +286,9 @@ int arch_set_info_guest(struct vcpu *v, struct vcpu_guest_context *c)
 
        *regs = c->regs;
        d->arch.sys_pgnr = c->sys_pgnr;
+       d->arch.initrd_start = c->initrd.start;
+       d->arch.initrd_len   = c->initrd.size;
+       d->arch.cmdline      = c->cmdline;
        new_thread(v, regs->cr_iip, 0, 0);
 
 #ifdef CONFIG_IA64_SPLIT_CACHE
@@ -364,6 +367,9 @@ void new_thread(struct vcpu *v,
                    regs->r28 = dom_fw_setup(d,saved_command_line,256L);
                else {
                    regs->ar_rsc |= (2 << 2); /* force PL2/3 */
+                   //regs->r28 = dom_fw_setup(d,d->arch.cmdline,256L);
+printf("construct domU: d->arch.cmdline=%p, firstchar=%d\n",
+d->arch.cmdline,*(d->arch.cmdline));
                    regs->r28 = dom_fw_setup(d,"nomca nosmp xencons=tty0 console=tty0 root=/dev/hda1",256L);  //FIXME
                }
                VCPU(v, banknum) = 1;
index 5d6aa93bf23ea89079b75f260b2c3e309fcc9807..524bd1c3480f77e9296ee03b3e003269d62a6550 100644 (file)
@@ -38,6 +38,9 @@ struct arch_domain {
     u64 image_len;
     u64 entry;
 #endif
+    unsigned long initrd_start;
+    unsigned long initrd_len;
+    char *cmdline;
 };
 #define xen_vastart arch.xen_vastart
 #define xen_vaend arch.xen_vaend
index bb7cd216bb8f9eab69cc1cf938802be9982a669a..7eaf856174c1f40a0dbada95dba57a4892c7e3a4 100644 (file)
@@ -276,6 +276,12 @@ typedef struct {
     unsigned long start_info_pfn;
 } arch_shared_info_t;
 
+typedef struct {
+    unsigned long start;
+    unsigned long size; 
+} arch_initrd_info_t;
+
+#define IA64_COMMAND_LINE_SIZE 512
 typedef struct vcpu_guest_context {
 #define VGCF_FPU_VALID (1<<0)
 #define VGCF_VMX_GUEST (1<<1)
@@ -289,6 +295,8 @@ typedef struct vcpu_guest_context {
     cpu_user_regs_t regs;
     arch_vcpu_info_t vcpu;
     arch_shared_info_t shared;
+    arch_initrd_info_t initrd;
+    char cmdline[IA64_COMMAND_LINE_SIZE];
 } vcpu_guest_context_t;
 
 #endif /* !__ASSEMBLY__ */